#parse('include.java')
#set($sp = $CSU.getSuperPackage($model.package,1))
#if($sp)
package ${sp}.dao;
#end
#set($constant = $type.toUpperCase())

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class ${model.name}Fields {

#foreach($model in $modelList)
public static final String[] fields = {##
#foreach($field in $model.fields)##
	"${field.name}"#if( $foreach.hasNext ),#end##
#end##
};
#end


#foreach($model in $modelList)
public static final Map<String,Boolean> field_map = new HashMap<String,Boolean>();
#end

static{
#foreach($model in $modelList)
	#foreach($field in $model.fields)
		field_map.put("${field.name}",  true);
	#end

#end
}

public static ${TYPE} copy(${TYPE} ${type}){
	${TYPE} new${TYPE} = new ${TYPE}();
	#foreach($field in $model.fields)
		#set($fw = $CSU.getHumpWord($field.name))
		new${TYPE}.set$fw(${type}.get$fw());
	#end
	return new${TYPE};
}

public static void main(String args[]){
#foreach($model in $modelList)
	////${model.name}
	System.out.println("//${model.name}");
	System.out.println("public static final String[] ${constant}_OUT = {");
	for(Entry<String,Boolean> entry:field_map.entrySet()){
		String name = entry.getKey();
		if(!check(name, OutputFilter.${constant})){
			System.out.print("\""+name);
			System.out.print("\",");
		}
	}
	System.out.println("null}");

#end
}

#*
#foreach($model in $modelList)
//${model.name}
public static final String[] ${constant} = {
	#foreach($field in $model.fields)"${field.name}"#if(!$foreach.last),#end#end
}
#end
*#

	private static boolean check(String name, String args[]){
		for(String s:args){
			if(s.equals(name)){
				return true;
			}
		}
		return false;
	}
}
